package com.ocom.payconfig.controller;

import com.ocom.common.constant.PayConfigUrl;
import com.ocom.common.entity.card.EntityXfMerchPayInfo;
import com.ocom.common.enums.ResultEnum;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.payconfig.service.XfMerchPayInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: TODO
 * @Author: 朱晖
 * @Date: 2022/7/28
 **/
@RestController
public class MerchPayInfoController {

	@Autowired
	private XfMerchPayInfoService xfMerchPayInfoService;

	@PostMapping(PayConfigUrl.Url_getPayInfo)
	public Result getPayInfo(@RequestBody  EntityXfMerchPayInfo entityXfMerchPayInfo){
		EntityXfMerchPayInfo entityXfMerchPayInfo1 = xfMerchPayInfoService.getPayInfo(entityXfMerchPayInfo.getComId(),
				entityXfMerchPayInfo);
		if(entityXfMerchPayInfo1 == null) return ResultUtil.error(ResultEnum.Err_3044);
		return ResultUtil.success(entityXfMerchPayInfo1);
	}



	@PostMapping(PayConfigUrl.Url_addPayInfo)
	public Result addPayInfo(@RequestBody EntityXfMerchPayInfo entityXfMerchPayInfo){
		EntityXfMerchPayInfo entityXfMerchPayInfo1 = xfMerchPayInfoService.addPayInfo(entityXfMerchPayInfo.getComId(),
				entityXfMerchPayInfo);
		if(entityXfMerchPayInfo1 == null) return ResultUtil.error(ResultEnum.Err_3044);
		return ResultUtil.success(entityXfMerchPayInfo1);
	}


	@PostMapping(PayConfigUrl.Url_delPayInfo)
	public Result delPayInfo(@RequestBody EntityXfMerchPayInfo entityXfMerchPayInfo){
		Boolean b = xfMerchPayInfoService.delPayInfo(entityXfMerchPayInfo.getComId(),
				entityXfMerchPayInfo);
		if(!b) return ResultUtil.error(ResultEnum.Err_3016);
		return ResultUtil.success();
	}

}
